// 
// SoapTrace.Net - A soap message monitoring utility. 
// 
// Copyright (C) 2004 Matthew Ward
// 
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
// 
// Matthew Ward (mrward@users.sourceforge.net)
// 

using System;
using System.Diagnostics;
using System.Xml.Serialization;

namespace SoapTrace.Core.Formatters
{
	/// <summary>
	/// Web service class.
	/// </summary>
	[ XmlType( "webservice" ) ]
	public class WebService : ICloneable
	{
		/// <summary>
		/// The web service's name.
		/// </summary>
		private string m_Name = String.Empty;

		/// <summary>
		/// The web service's Uri.
		/// </summary>
		private string m_Uri = String.Empty;

		/// <summary>
		/// The operations for this web service.
		/// </summary>
		private WebServiceOperationCollection m_Operations = 
			new WebServiceOperationCollection( );

		/// <summary>
		/// Creates a new instance of this class.
		/// </summary>
		public WebService( )
		{
		}

		/// <summary>
		/// The name of this web service.
		/// </summary>
		[ XmlAttribute( "name" ) ]
		public string Name
		{
			[ DebuggerStepThrough ]
			get
			{
				return m_Name;
			}

			[ DebuggerStepThrough ]
			set
			{
				m_Name = value;
			}
		}

		/// <summary>
		/// The web service uri.  This will be the URI as
		/// request in a GET http request.  It does not include the
		/// server or port (e.g. /MyWebServices/DoStuff.asmx)
		/// </summary>
		[ XmlAttribute( "uri" ) ]
		public string Uri
		{
			[ DebuggerStepThrough ]
			get
			{
				return m_Uri;
			}

			[ DebuggerStepThrough ]
			set
			{
				m_Uri = value;
			}
		}

		/// <summary>
		/// The operations available on this web service.
		/// </summary>
		[ XmlElement( "operation" ) ]
		public WebServiceOperationCollection Operations
		{
			[ DebuggerStepThrough ]
			get
			{
				return m_Operations;
			}
		}

		#region ICloneable Members

		/// <summary>
		/// Creates a deep copy of this object.
		/// </summary>
		/// <returns></returns>
		public object Clone( )
		{
			WebService WebService = new WebService( );

			WebService.Name = String.Copy( Name );
			
			WebService.Operations.AddRange( ( WebServiceOperationCollection )Operations.Clone( ) );

			return WebService;
		}

		#endregion
	}
}
